<?php

namespace Portal\UserBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class UserRegisterType extends AbstractType
{
  
  private $locationArray;
  
  public function __construct($locationArray)
  {
    $this->locationArray = $locationArray;
  }
  
  public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('email', 'email',  array())            
            ->add('password', 'password', array())
            ->add('firstName', null, array())
            ->add('lastName', null, array())
//            ->add('roles')
            ->add('phone', null, array('max_length' => 10))
            ->add('location', 'choice', array(                
                'choices' => $this->locationArray,
                'required' => true,
                'expanded' => false,
                'multiple' => false
            ))
            //->add('location', 'entity', array('class' => 'Portal\UserBundle\Entity\Location', 'property' => 'name', 'empty_data' => 'Сонгох'))
//            ->add('createdAt')
        ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Portal\UserBundle\Entity\User'
        ));
    }

    public function getName()
    {
        return 'portal_userbundle_userregistertype';
    }
}
